home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Development Platforms / Apple II / Apple II Sample Code / MPW IIGS SC / SC.010.PlaySound / PlaySound.init.aii < prev    next >
Encoding:
Text File  |  1990-06-24  |  7.4 KB  |  359 lines  |  [TEXT/MPS ]

  1. *******************************************************************************
  2. *
  3. * PlaySound.init.aii -- Version 3.0
  4. *
  5. * (C)  Copyright Apple Computer, Inc. 1988-1990
  6. * All rights reserved.
  7. *
  8. * Developer Technical Support Apple II Sample Code
  9. *
  10. * by Jim Mensch & Keith Rollin
  11. *
  12. * This file contains standard routines used by all the applications on the DTS
  13. * Demo Disk. This file relies on certain data structures being available in a GLOBALS
  14. * data record in the main file. This file has been modified to not create menus
  15. * and to start up standard file and the sound tools.
  16. *
  17. *******************************************************************************
  18.     PRINT PUSH,OFF
  19.  
  20.     EJECT
  21. *******************************************************************************
  22. *
  23. InitTools    PROC
  24. *
  25. * Description:    Load and initialize the tools needed. Errors are detected
  26. *    and FatalError is called if any occur. If there aren't any
  27. *    errors, the list of menu templates is read and the menu-
  28. *    bar is created.
  29. *
  30. *
  31. * Inputs:    NONE
  32. *
  33. * Outputs:    NONE
  34. *
  35. * External Refs:
  36.     import FatalError
  37. *
  38. * Entry Points:    NONE
  39. *
  40. *******************************************************************************
  41.     with Globals
  42.  
  43. ;
  44. ;   Tool Direct page offsets here
  45. ;
  46. QDDPage    equ $0000
  47. EMDPage    equ QDDPage+$0300
  48. CtlDPage    equ EMDPage+$0100
  49. MenuDPage    equ CtlDPage+$0100
  50. LEDPage    equ MenuDPage+$0100
  51. SFDPage    equ LEDPage+$0100
  52. SoundDPage    equ SFDPage+$0100
  53. ToolDPSize    equ SoundDPage+$0100
  54.  
  55.     phk    ; Save program bank register and
  56.     plb    ; load it as the data bank register
  57.  
  58.     tdc
  59.     sta MyDP    ; Save direct register
  60.  
  61.     _TLStartup    ; Start Tool Locator
  62.  
  63.     pha    ; Space for result
  64.     _MMStartup    ; Start memory manager
  65.     PullWord MyID    ; Save it for later use
  66.  
  67.     _MTStartup    ; Start up Misc Tools
  68.  
  69.     _IMStartup    ; Start integer math toolset
  70.  
  71.     PushLong #ToolTable    ; Pointer to Tool table
  72.     _LoadTools    ; Load all RAM based tools
  73.     bcc IT0005    ; Carry clear means no error
  74.     brl FatalError    ; Tools can't be loaded. Fatal error!
  75.  
  76. IT0005
  77.  
  78. ; Get memory for Tool Direct pages
  79.  
  80.     pha    ; Room for result
  81.     pha
  82.     PushLong #ToolDPSize; Number of bytes needed
  83.     PushWord MyID    ; ID of this application
  84.     PushWord #attrLocked+attrFixed+attrPage+attrBank
  85.     PushLong #0    ; Allocate them in bank 0
  86.     _NewHandle
  87.     bcc IT0010    ; Test carry for error
  88.     brl FatalError    ; If no memory we got a fatal error!
  89.  
  90. IT0010    PullLong DPHandle    ; Retrieve handle to our DPage area
  91.  
  92.     lda [DPHandle]    ; Dereference the handle to get a ptr
  93.     sta DPPointer    ; to our direct page area and save it.
  94.  
  95.     PushWord DPPointer    ; QuickDraw uses 3 pages of Dpage
  96.     PushWord #ScreenMode; Used to set all master SCB's
  97.     PushWord #0    ; Zero means use default buf size
  98.     PushWord MyID    ; Application ID for allocating data
  99.     _QDStartup    ; Start QuickDraw, turn on SHR Screen
  100.     bcc IT0015
  101.     brl FatalError    ; If it can't be started then bomb
  102.  
  103. IT0015
  104.     lda DPPointer    ; Create address for Event Mgr DPage by
  105.     clc    ; loading in the pointer to the start
  106.     adc #EMDPage    ; of DPage and adding Evt Mgr offset.
  107.     pha    ; Now push it on the stack.
  108.     PushWord #20    ; Size of event queue.
  109.     PushWord #0    ; MouseClamp values.
  110.     PushWord #ScreenWidth ; These will clamp mouse to screen
  111.     PushWord #0    ; area only.
  112.     PushWord #200
  113.     PushWord MyID
  114.     _EMStartup    ; Start the event manager
  115.     bcc IT0020
  116.     brl FatalError    ; Event manager is also a must
  117. IT0020
  118.     PushWord MyID
  119.     _WindStartup
  120.     bcc IT0025
  121.     brl FatalError
  122. IT0025
  123.     PushWord MyID
  124.     lda DPPointer
  125.     clc
  126.     adc #CtlDPage
  127.     pha
  128.     _CtlStartup
  129.     bcc IT0030
  130.     brl FatalError
  131. IT0030
  132.  
  133.     PushWord MyID
  134.     lda DPPointer
  135.     clc
  136.     adc #MenuDPage
  137.     pha
  138.     _MenuStartUp
  139.     bcc IT0035
  140.     brl FatalError
  141. IT0035
  142.     PushWord MyID
  143.     lda DPPointer
  144.     clc
  145.     adc #LEDPage
  146.     pha
  147.     _LEStartUp
  148.     bcc IT0040
  149.     brl FatalError
  150. IT0040
  151.     PushWord MyID
  152.     _DialogStartup
  153.     bcc IT0045
  154.     brl FatalError
  155. IT0045
  156.     PushWord MyID
  157.     lda DPPointer
  158.     clc
  159.     adc #SFDPage
  160.     pha
  161.     _SFStartUp
  162.     bcc IT0050
  163.     brl FatalError
  164. IT0050
  165.     lda DPPointer
  166.     clc
  167.     adc #SoundDPage
  168.     pha
  169.     _SoundStartup
  170.     bcc IT0055
  171.     brl FatalError
  172. IT0055
  173.     _ScrapStartup    ; No errors possible for this call
  174.  
  175.     _DeskStartup    ; No error possible for this call
  176.  
  177.     PushLong #0
  178.     _RefreshDeskTop
  179.  
  180.  
  181.     RTS
  182.  
  183. ToolTable    dc.W 7    ; Data Block for LoadTools call
  184.     dc.W 14,$0100    ; Window Manager
  185.     dc.W 15,$0100    ; Menu Manager
  186.     dc.W 16,$0100    ; Control Manager
  187.     dc.W 20,$0100    ; LineEdit tool set
  188.     dc.W 21,$0100    ; Dialog Manager
  189.     dc.W 22,$0100    ; Scrap manager
  190.     dc.W 23,$0100    ; standard file
  191.  
  192.     ENDP
  193.  
  194.     EJECT
  195. *******************************************************************************
  196. *
  197. FatalError    PROC
  198. *
  199. * Description:    Routine that is called whenever a tool sends back an error
  200. *    that can not be recovered from. This routine prints the
  201. *    error on the screen, waits for a keypress then quits back
  202. *    to whoever started this application up!
  203. *
  204. *
  205. * Inputs:    A = Error number
  206. *
  207. * Outputs:    NONE (program exits)
  208. *
  209. * External Refs:
  210.     import CloseTools
  211. *
  212. * Entry Points:    NONE
  213. *
  214. *******************************************************************************
  215.     with Globals
  216.  
  217.     pha    ; Push the error code
  218.     PushLong #ErrNumStr    ; Address of storage area
  219.     PushWord #4    ; Length of string
  220.     _Int2Hex
  221.  
  222.     _GrafOff    ; If QD Started, shut off graphics
  223.  
  224.     PushLong #ErrStr    ; Write error message to the screen
  225.     _WriteCString
  226.  
  227.     pha    ; Space for result
  228.     PushWord #0    ; No echo
  229.     _ReadChar    ; Wait for a key to be pressed
  230.     pla    ; Discard the key
  231.  
  232.     jsr CloseTools    ; Shut down all the tools in case
  233. ;          any got started up
  234.  
  235.     _Quit QuitParms    ; Quit back to where we came from.
  236.  
  237.     brk $FF    ; If the quit fails then just break
  238.     
  239. ErrStr    dc.B 'A fatal error has occured $'
  240. ErrNumStr    dc.B 'xxxx   press any key to exit',0
  241.  
  242.     ENDP
  243.  
  244.     EJECT
  245. *******************************************************************************
  246. *
  247. CloseTools    PROC
  248. *
  249. * Description:    Shut down the tools I started.
  250. *
  251. *
  252. * Inputs:    NONE
  253. *
  254. * Outputs:    NONE
  255. *
  256. * External Refs:    NONE
  257. *
  258. * Entry Points:    NONE
  259. *
  260. *******************************************************************************
  261.     with Globals
  262.  
  263.     _DeskShutDown
  264.     _ScrapShutDown
  265.     _SoundShutDown
  266.     _DialogShutDown
  267.     _LEShutDown
  268.     _MenuShutDown
  269.     _CtlShutDown
  270.     _WindShutDown
  271.     _EMShutDown
  272.     _QDShutDown
  273.     _MTShutDown
  274.  
  275.     PushLong DPHandle    ; Dispose of all that DP memory
  276.     _DisposeHandle
  277.  
  278.     PushWord MyID
  279.     _MMShutDown
  280.     _TLShutDown
  281.  
  282.     rts
  283.     ENDP
  284.  
  285.     EJECT
  286. *******************************************************************************
  287. *
  288. doAbout    PROC
  289. *
  290. * Description:    Bring up an Alert Dialog box with our name in it.
  291. *
  292. * Inputs:    NONE
  293. *
  294. * Outputs:    NONE
  295. *
  296. * External Refs:    NONE
  297. *
  298. * Entry Points:    NONE
  299. *
  300. *******************************************************************************
  301.     With Globals
  302.  
  303.     pha    ; space for result
  304.     PushLong #AboutBox    ; pointer to alert template
  305.     PushLong #0    ; pointer to a filter proc (0=none)
  306.     _NoteAlert
  307.     pla    ; get the item hit and dispose
  308.  
  309.     rts
  310.  
  311. ; About Box alert template
  312.  
  313. AboutBox    dc.W 30,30,100,590    ; for 320 use 30,30,100,290
  314.     dc.W 1    ; this is alert # 1
  315.     dc.B $80    ; draw for this stage
  316.     dc.B $81    ; draw for this stage
  317.     dc.B $82    ; draw for this stage
  318.     dc.B $83    ; draw for this stage
  319.     dc.L OKButton    ; ok button for the    alert
  320.     dc.L AboutTitle    ; title of the program
  321.     dc.L AboutAut    ; author
  322.     dc.L AboutVers    ; version number string
  323.     dc.L 0    ; nil to end the list
  324.  
  325. OKBTitle    dc.B 2,'OK'
  326. OKButton    dc.W 1
  327.     dc.W 50,500,65,550
  328.     dc.W buttonItem
  329.     dc.L OKBTitle
  330.     dc.W 0
  331.     dc.W 0    ; item flag
  332.     dc.L 0    ; no color table
  333.  
  334. AboutTitle    dc.W 2
  335.     dc.W 10,100,20,550
  336.     dc.W statText+itemDisable
  337.     dc.L TitleString
  338.     dc.W 0
  339.     dc.W 0    ; item flag
  340.     dc.L 0    ; no color table
  341.  
  342. AboutAut    dc.W 3
  343.     dc.W 25,100,35,550
  344.     dc.W statText+itemDisable
  345.     dc.L AutString
  346.     dc.W 0
  347.     dc.W 0    ; item flag
  348.     dc.L 0    ; no color table
  349.  
  350. AboutVers    dc.W 4
  351.     dc.W 40,100,50,550
  352.     dc.W statText+itemDisable
  353.     dc.L VersString
  354.     dc.W 0
  355.     dc.W 0    ; item flag
  356.     dc.L 0    ; no color table
  357.  
  358.     ENDP
  359.